package cn.iocoder.yudao.module.system.dal.mysql.roledevice;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.roledevice.RoleDeviceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.roledevice.vo.*;

/**
 * 设备和角色关联 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface RoleDeviceMapper extends BaseMapperX<RoleDeviceDO> {

    default PageResult<RoleDeviceDO> selectPage(RoleDevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RoleDeviceDO>()
                .eqIfPresent(RoleDeviceDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(RoleDeviceDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(RoleDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RoleDeviceDO::getId));
    }

    void deleteByRoleId(Long roleId);
}